﻿Option Explicit On
Imports System.Text
Imports Global_Visas_Business_Layer
Imports System.ComponentModel
Partial Public Class frmAddPerson
    Public _Dependant As Long
    Public _ChildDesc As String
    Public _ParentDesc As String

    Private Sub frmAddPerson_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Input.KeyEventArgs) Handles Me.KeyUp
        If e.Key = Key.Escape Then
            Me.Close()
        End If
    End Sub

    Private Sub frmAddPerson_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
        GeneralTasks.ChangeTheme(Me)
        GeneralTasks.EnumerateandFill(Me.LogicalChildren)
        With Me.drpDest
            .DisplayMemberPath = "country_name"
            .SelectedValuePath = "country_id"
            .ItemsSource = CType(CommonDataFunctions.CountryList, IListSource).GetList
            .SelectedIndex = -1
        End With
        With Me.drpRes
            .DisplayMemberPath = "country_name"
            .SelectedValuePath = "country_id"
            .ItemsSource = CType(CommonDataFunctions.CountryList, IListSource).GetList
            .SelectedIndex = -1
        End With

        With Me.drpNat
            .DisplayMemberPath = "country_nationality"
            .SelectedValuePath = "country_id"
            .ItemsSource = CType(CommonDataFunctions.NationalityList, IListSource).GetList
            .SelectedIndex = -1
        End With

        With Me.drpUKVisa
            .DisplayMemberPath = "ukvisa_name"
            .SelectedValuePath = "ukvisa_id"
            .ItemsSource = CType(CommonDataFunctions.UKVisaList, IListSource).GetList
            .SelectedIndex = -1
        End With

        With Me.drpTitle
            .DisplayMemberPath = "title_text"
            .SelectedValuePath = "title_id"
            .ItemsSource = CType(CommonDataFunctions.TitleList(""), IListSource).GetList
            .SelectedIndex = -1
        End With


        With Me.drpQual
            .DisplayMemberPath = "qual_name"
            .SelectedValuePath = "qual_id"
            .ItemsSource = CType(CommonDataFunctions.QualificationList, IListSource).GetList
            .SelectedIndex = -1
        End With

        With Me.drpRelationship
            .DisplayMemberPath = "role_name"
            .SelectedValuePath = "role_id"
            .ItemsSource = CType(Company.CompanyRoleList, IListSource).GetList
            .SelectedIndex = -1
        End With

        With Me.drpWhereHear
            .DisplayMemberPath = "wherehear_text"
            .SelectedValuePath = "wherehear_id"
            .ItemsSource = CType(CommonDataFunctions.WhereHearList, IListSource).GetList
            .SelectedIndex = -1
        End With

        ' for companies show Role
        ' for private individuals show Where Hear
        If GlobalCRM.CurrentCompanyID > 0 Then
            Me.lblRelationship.Visibility = Windows.Visibility.Visible
            Me.drpRelationship.Visibility = Windows.Visibility.Visible
            txtCompanyID.Text = GlobalCRM.CurrentCompanyID.ToString
            txtCompanyID.IsReadOnly = True
            'xxx can we take this out and control via txtCompanyID?
            'lblCompanyId.Visible = True
            'lblCompanyId.Text = GlobalCRM.CurrentCompanyID.ToString
            Me.grpAdvert.Visibility = Windows.Visibility.Hidden
            Me.lblWhereHear.Visibility = Windows.Visibility.Hidden
            Me.drpWhereHear.Visibility = Windows.Visibility.Hidden
        Else
            Me.lblRelationship.Visibility = Windows.Visibility.Hidden
            Me.drpRelationship.Visibility = Windows.Visibility.Hidden
            txtCompanyID.Text = String.Empty
            txtCompanyID.IsEnabled = False
            Me.grpAdvert.Visibility = Windows.Visibility.Visible
            Me.lblWhereHear.Visibility = Windows.Visibility.Visible
            Me.drpWhereHear.Visibility = Windows.Visibility.Visible
        End If

    End Sub
    Private Sub QuickNatButtons(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAU.Click, btnNZ.Click, btnSA.Click, btnUK.Click, btnQ.Click, btnCA.Click

        Dim myBtn As Button = CType(sender, Button)

        Me.drpDest.SelectedValue = myBtn.Tag 'GlobalCRM.COUNTRY_UK 'myBtn.Tag
        Me.drpNat.SelectedValue = myBtn.Tag
        Me.drpRes.SelectedValue = myBtn.Tag

        If myBtn.Tag <> GlobalCRM.COUNTRY_UNKNOWN Then
            Me.drpUKVisa.SelectedValue = GlobalCRM.UKVISA_NONE
        Else
            Me.drpUKVisa.SelectedValue = GlobalCRM.UKVISA_UNKNOWN
        End If

    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnCancel.Click
        Me.Close()

    End Sub

    Private Sub btnDOB_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnDOB.Click
        Me.txtDOB.Text = CommonFuncs.GetPopUpCalendarDate(Me.txtDOB.Text)
    End Sub

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnSave.Click
        Dim cmn As New CommonFuncs
        Dim tsk As New TasksEvents

        Dim PersonId As Long
        Dim myPerson As People.PersonInfo
        Dim bFail As Boolean = True

        ' check form validation is ok
        If Not Me.ValidateForm() Then
            Exit Sub
        End If

        ' get person details from form
        myPerson = New People.PersonInfo

        With myPerson
            .Firstname = Me.txtFirstName.Text.Trim
            .Surname = Me.txtSurname.Text.Trim
            .Title = Me.drpTitle.Text.Trim
            .NationalityId = Me.drpNat.SelectedValue
            .ResidenceId = Me.drpRes.SelectedValue
            .UKVisaId = Me.drpUKVisa.SelectedValue
            .DestinationId = Me.drpDest.SelectedValue
            .JobTitle = Me.txtJobTitle.Text.Trim
            .Salary = Me.txtSalary.Text.Trim
            .Qualification = Me.drpQual.Text.Trim
            .PassportNo = Me.txtPassportNo.Text.Trim
            If IsDate(Me.txtDOB.Text) Then
                .DOB = Me.txtDOB.Text.Trim
            Else
                .DOB = Nothing
            End If
            If IsDate(Me.txtVisaExpiry.Text) Then
                If CDate(Me.txtVisaExpiry.Text) < cmn.FormatDate(Now) Then
                    Dim checkdate As Integer
                    checkdate = MsgBox("Visa Expiry date is in the past. Are you sure to continue?", MsgBoxStyle.YesNo, "Expiry Date in Past")
                    If checkdate <> 6 Then

                        Exit Sub
                    End If
                End If
                .UKVisaExpiry = Me.txtVisaExpiry.Text.Trim
            Else
                .UKVisaExpiry = Nothing
            End If
            If IsDate(Me.txtPassExp.Text) Then
                .PassportExp = Me.txtPassExp.Text.Trim
            Else
                .PassportExp = Nothing
            End If
            If Me.drpRelationship.SelectedIndex > -1 Then
                .CompanyId = GlobalCRM.CurrentCompanyID
                .CompanyRoleId = Me.drpRelationship.SelectedValue
                .AccountManagerId = 0
            Else
                .CompanyId = 0
                .CompanyRoleId = 0
                .AccountManagerId = GlobalCRM.CurrentConID
            End If
        End With

        Try
            CommonFuncs.BeginTrans()

            ' add person details to database
            PersonId = People.AddPerson(myPerson, Nothing)

            ' if add person method failed exit
            If PersonId = 0 Then
                CommonFuncs.DisplayMessage("The person's details could not be added to the database.", CommonDialog.CustomDialogIcons.Information, "Error")
                CommonFuncs.RollbackTrans()
                Exit Sub
            End If

            If Me.txtCompanyID.Text = String.Empty Then
                If People.AddAdvertising(Me.drpWhereHear.Text, GlobalCRM.CurrentConName, PersonId) = 0 Then
                    If MsgBox("How the person heard about Global Visas could not be added to the database. Do you wish to continue?", MsgBoxStyle.YesNo, "Error") = MsgBoxResult.No Then
                        CommonFuncs.RollbackTrans()
                        Exit Sub
                    End If
                End If
            End If

            ' xxx replaced with txtCompanyID block above. Delete this
            'If Me.lblCompanyId.Visible = False Then
            '    If People.AddAdvertising(Me.drpWhereHear.Text, GlobalCRM.CurrentConName, PersonId) = 0 Then
            '        Exit Sub
            '    End If
            'End If

            If Me.txtEmail.Text.Trim <> "" Then
                'If People.AddEmailAddress(Me.txtEmail.Text, Me.txtEmailName.Text, GlobalCRM.CurrentConName, PersonId) = 0 Then
                If People.AddEmailAddress(Me.txtEmailName.Text, Me.txtEmail.Text, PersonId, True, GlobalCRM.CurrentConName) = 0 Then
                    If MsgBox("The person's email address could not be added to the database. Do you wish to continue?", MsgBoxStyle.YesNo, "Error") = MsgBoxResult.No Then
                        CommonFuncs.RollbackTrans()
                        Exit Sub
                    End If
                End If
            End If

            If Me.txtPhoneMain.Text.Trim <> "" Then
                If People.AddPhoneNumber(Me.txtPhoneMain.Text, Me.txtPhoneMainName.Text, GlobalCRM.CurrentConName, PersonId, People.PhoneTypes.PhoneMain, GlobalCRM.CurrentCompanyID) = 0 Then
                    If MsgBox("The person's phone number could not be added to the database. Do you wish to continue?", MsgBoxStyle.YesNo, "Error") = MsgBoxResult.No Then
                        CommonFuncs.RollbackTrans()
                        Exit Sub
                    End If
                End If
            End If

            If Me.txtPhoneFax.Text.Trim <> "" Then
                If People.AddPhoneNumber(Me.txtPhoneFax.Text, Me.txtPhoneFaxName.Text, GlobalCRM.CurrentConName, PersonId, People.PhoneTypes.PhoneFax, GlobalCRM.CurrentCompanyID) = 0 Then
                    If MsgBox("The person's fax number could not be added to the database. Do you wish to continue?", MsgBoxStyle.YesNo, "Error") = MsgBoxResult.No Then
                        CommonFuncs.RollbackTrans()
                        Exit Sub
                    End If
                End If
            End If

            If Me.txtPhoneOther.Text.Trim <> "" Then
                If People.AddPhoneNumber(Me.txtPhoneOther.Text, Me.txtPhoneOtherName.Text, GlobalCRM.CurrentConName, PersonId, People.PhoneTypes.PhoneOther, GlobalCRM.CurrentCompanyID) = 0 Then
                    If MsgBox("The person's other number could not be added to the database. Do you wish to continue?", MsgBoxStyle.YesNo, "Error") = MsgBoxResult.No Then
                        CommonFuncs.RollbackTrans()
                        Exit Sub
                    End If
                End If
            End If

            If Me.lblParentID.Visibility Then
                'Sumathivinayak S - Made a split of the if statement to nesting loop
                ' was erroring when you add a new person who has no parent id.
                ' check if visible, if yes, then check for text value
                If Me.lblParentID.Content > 0 Then    'Me._Dependant <> 0
                    'Form was called from dependants screen on another user, this person is to be a dependant of them.

                    Dim PublicRelationship As Boolean

                    If Me.txtCompanyID.Text <> "" Then
                        If MsgBox("Should this be a public relationship? (i.e. visible in company tracking system)", vbYesNo, "Confirm status") = MsgBoxResult.Yes Then
                            PublicRelationship = True
                        End If
                    End If

                    ' xxx replaced with txtCompanyID block above. Delete this
                    'If Me.lblCompanyId.Visible Then
                    '    If MsgBox("Should this be a public relationship? (i.e. visible in company tracking system)", vbYesNo, "Confirm status") = MsgBoxResult.Yes Then
                    '        PublicRelationship = True
                    '    End If
                    'End If

                    If People.AddDependant(GlobalCRM.CurrentCandidateID, PersonId, Me.lblParentDesc.Content, Me.lblChildDesc.Content, GlobalCRM.CurrentConName, PublicRelationship) > 0 Then
                        tsk.GblFunc_Add_SysEvent("Activity", "New private individual added (" & PersonId & ") as dependant ( to " & Me._Dependant & ")")
                        tsk.GblFunc_Add_Event("Dependant Added", Me.txtFirstName.Text.Trim & " " & Me.txtSurname.Text.Trim & " added to system (" & PersonId & ") and listed as a dependant of " & People.GetPersonName(Me._Dependant), TasksEvents.EventStatus.SingleEvent, Me._Dependant, 2)
                        CommonDataFunctions.GblFunc_Goto_ID(PersonId, CommonFuncs.DBIdTypes.PersonID)
                    End If

                Else
                    If Me.txtCompanyID.Text <> "" Then
                        'If Me.lblCompanyId.Visible Then
                        tsk.GblFunc_Add_SysEvent("Activity", "New person added to company no. " & Me.txtCompanyID.Text.ToString & " (" & PersonId & ")")
                        tsk.GblFunc_Add_Event("Person Added", Me.txtFirstName.Text.Trim & " " & Me.txtSurname.Text.Trim & " added as " & Me.drpRelationship.Text, TasksEvents.EventStatus.SingleEvent, Me.txtCompanyID.Text, TasksEvents.LinkTypes.Company)

                    Else
                        tsk.GblFunc_Add_SysEvent("Activity", "New private individual added (" & PersonId & ")")
                    End If


                    CommonDataFunctions.GblFunc_Goto_ID(PersonId, CommonFuncs.DBIdTypes.PersonID)
                End If
            End If
            CommonFuncs.CommitTrans()

            bFail = False
            GlobalCRM.CurrentCandidateID = PersonId

            'Dim frmCRMMainDisplay As New frmCRMMainDisplay

            'frmMainDisplay.MdiParent = frmMDIMain

            'Try


            '    frmCRMMainDisplay.ActiveTab = frmCRMMainDisplay.PageTabs.Person


            '    Me.Close()
            'Catch ex As Exception
            'Finally
            '    frmCRMMainDisplay = Nothing
            'End Try
            Me.Close()
        Catch ex As Exception
            CommonFuncs.DisplayMessage("There was an error saving the person." & vbCrLf & "Please retry then ask support if no success.", CommonDialog.CustomDialogIcons.Information, "Assign Case Worker")
            If CommonFuncs.IsTransactionOpen = True Then
                CommonFuncs.RollbackTrans()
            End If
            'CommonFunc.ErrorHandler(ex, "frmAddPerson.btnSave_Click", True)
        Finally
            cmn = Nothing
            tsk = Nothing
            If bFail = True Then
                CommonFuncs.DisplayMessage("There was an error saving the person." & vbCrLf & "Please retry then ask support if no success.", CommonDialog.CustomDialogIcons.Information, "Assign Case Worker")
            End If
        End Try
    End Sub
    Private Function ValidateForm() As Boolean

        Dim Ret, ExpDate As Integer

        If Me.txtSurname.Text.Trim = String.Empty Then
            CommonFuncs.DisplayMessage("You must provide a surname for the person", CommonDialog.CustomDialogIcons.Information, "Surname")
            Me.txtSurname.Focus()
            Exit Function
        End If

        If Me.txtSurname.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage("Surname is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Surname")
            Me.txtSurname.Focus()
            Exit Function
        End If

        If Me.txtFirstName.Text.Trim = String.Empty Then
            CommonFuncs.DisplayMessage("You must provide a first name for the person", CommonDialog.CustomDialogIcons.Information, "First Name")
            Me.txtFirstName.Focus()
            Exit Function
        End If

        If Me.txtFirstName.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage("First name is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "First Name")
            Me.txtFirstName.Focus()
            Exit Function
        End If

        If Me.txtDOB.Text.Trim <> String.Empty Then
            'DoB provided, validate
            If Not IsDate(Me.txtDOB.Text.Trim) Then
                CommonFuncs.DisplayMessage("Please enter a valid DoB", CommonDialog.CustomDialogIcons.Information, "DoB")
                Me.txtDOB.Focus()
                Exit Function
            End If

            If (CDate(Me.txtDOB.Text).Year < Now.Year - 100 Or CDate(Me.txtDOB.Text).Year > Now.Year) Then
                CommonFuncs.DisplayMessage("Date of birth is outside valid range", CommonDialog.CustomDialogIcons.Information, "DoB")
                Me.txtDOB.Focus()
                Exit Function
            End If
        End If

        If Me.txtJobTitle.Text.Trim.Length > 100 Then
            CommonFuncs.DisplayMessage("Jobtitle is too long (Max 100 chars)", CommonDialog.CustomDialogIcons.Information, "Job Title")
            Me.txtJobTitle.Focus()
            Exit Function
        End If

        If Me.txtSalary.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage("Salary is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Salary")
            Me.txtSalary.Focus()
            Exit Function
        End If

        If Me.drpRelationship.Visibility = Windows.Visibility.Visible And Me.drpRelationship.SelectedIndex = -1 Then
            CommonFuncs.DisplayMessage("You must select this persons relationship to the company", CommonDialog.CustomDialogIcons.Information, "Relationship")
            Me.drpRelationship.Focus()
            Exit Function
        End If

        If Me.txtPhoneMainName.Text.Length > 50 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneMainName.Text.Trim & " Phone Number name is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Phone Number")
            Me.txtPhoneMainName.Focus()
            Exit Function
        End If

        If Me.txtPhoneMain.Text.Length > 100 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneMainName.Text.Trim & " Phone Number is too long (Max 100 chars)", CommonDialog.CustomDialogIcons.Information, "Phone Main name")
            Me.txtPhoneMain.Focus()
            Exit Function
        End If

        If Me.txtPhoneFaxName.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneFaxName.Text.Trim & " Phone Number name is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Fax")
            Me.txtPhoneFaxName.Focus()
            Exit Function
        End If

        If Me.txtPhoneFax.Text.Trim.Length > 100 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneFax.Text.Trim & " Phone Number is too long (Max 100 chars)", CommonDialog.CustomDialogIcons.Information, "Fax")
            Me.txtPhoneFax.Focus()
            Exit Function
        End If

        If Me.txtPhoneOtherName.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneOtherName.Text.Trim & " Phone Number name is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Other")
            Me.txtPhoneOtherName.Focus()
            Exit Function
        End If

        If Me.txtPhoneOther.Text.Trim.Length > 100 Then
            CommonFuncs.DisplayMessage(Me.txtPhoneOther.Text.Trim & " Phone Number is too long (Max 100 chars)", CommonDialog.CustomDialogIcons.Information, "Other")
            Me.txtPhoneOther.Focus()
            Exit Function
        End If

        If Me.txtEmailName.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage(" E-Mail name is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "E-Mail")
            Me.txtEmailName.Focus()
            Exit Function
        End If

        If Me.txtEmail.Text.Trim.Length > 200 Then
            CommonFuncs.DisplayMessage("Email address is too long (Max 200 chars)", CommonDialog.CustomDialogIcons.Information, "E-Mail")
            Me.txtEmail.Focus()
            Exit Function
        End If

        If Me.drpDest.SelectedIndex = -1 Then
            CommonFuncs.DisplayMessage("You must enter a Destination", CommonDialog.CustomDialogIcons.Information, "Destination")
            Me.drpDest.Focus()
            Exit Function
        End If

        If Me.drpNat.SelectedIndex = -1 Then
            CommonFuncs.DisplayMessage("You must select a nationality for this person", CommonDialog.CustomDialogIcons.Information, "Nationality")
            Me.drpNat.Focus()
            Exit Function
        End If

        If Me.drpRes.SelectedIndex = -1 Then
            CommonFuncs.DisplayMessage("You must select the country of residence", CommonDialog.CustomDialogIcons.Information, "Country")
            Me.drpRes.Focus()
            Exit Function
        End If

        If Me.drpUKVisa.Text.Trim = String.Empty Then
            If MsgBox("You have not selected a UK visa status. Shall I select 'Unknown' and let you continue?", MsgBoxStyle.YesNo, "Visa") = MsgBoxResult.Yes Then
                Me.drpUKVisa.SelectedValue = 36
            Else
                Me.drpUKVisa.Focus()
                Exit Function
            End If
        End If

        If Me.txtVisaExpiry.Text.Trim <> "" Then
            ' validate supplied visa expiry date
            If Not IsDate(Me.txtVisaExpiry.Text) Then
                CommonFuncs.DisplayMessage("Please enter a valid UK Visa Expiry Date", CommonDialog.CustomDialogIcons.Information, "Expiry")
                Me.txtVisaExpiry.Focus()
                Exit Function
            End If

            If (CDate(Me.txtVisaExpiry.Text).Year < 1950 Or CDate(Me.txtVisaExpiry.Text).Year > 2050) Then
                CommonFuncs.DisplayMessage("UK Visa Expiry date is outside valid range", CommonDialog.CustomDialogIcons.Information, "Expiry")
                Me.txtVisaExpiry.Focus()
                Exit Function
            End If
            'If Me.txtVisaExpiry.Text.Trim <> "" Then
            '    If CDate(Me.txtVisaExpiry.Text) < Date.Now Then
            '        Dim checkdate As Integer
            '        checkdate = MsgBox("Visa Expiry date is in the past. Are you sure to continue?", MsgBoxStyle.YesNo, "Expiry Date in Past")
            '        If checkdate <> 6 Then
            '            Exit Function
            '        End If
            '    End If
            'End If
        End If

        ' set ExpDate value for uk visa verification (below)
        If Me.txtVisaExpiry.Text.Trim <> "" Then
            ExpDate = 1
        End If

        ' verify uk visa selection
        Ret = CommonDataFunctions.GblFunc_Validate_NatResVisa(Me.drpNat.SelectedValue, Me.drpRes.SelectedValue, Me.drpUKVisa.SelectedValue, ExpDate, 1)
        Select Case Ret
            Case 0, 4, 5
                'Ok to proceed
            Case Else
                'failed validation
                CommonFuncs.DisplayMessage("Failed Nationality / Residence / Visa Validation", CommonDialog.CustomDialogIcons.Information, "Validation")
                Exit Function
        End Select

        If Me.txtPassportNo.Text.Trim.Length > 50 Then
            CommonFuncs.DisplayMessage("Passport No. is too long (Max 50 chars)", CommonDialog.CustomDialogIcons.Information, "Passport number")
            Me.txtPassportNo.Focus()
            Exit Function
        End If

        If Me.txtPassExp.Text.Trim <> "" Then
            'Passport expiry provided, validate
            If Not IsDate(Me.txtPassExp.Text) Then
                CommonFuncs.DisplayMessage("Please enter a valid passport expiry Date", CommonDialog.CustomDialogIcons.Information, "Expiry")
                Me.txtPassExp.Focus()
                Exit Function
            End If

            If (CDate(Me.txtPassExp.Text).Year < 195.0R Or CDate(Me.txtPassExp.Text).Year > 2100) Then
                CommonFuncs.DisplayMessage("Passport expiry date is outside valid range", CommonDialog.CustomDialogIcons.Information, "Expiry")
                Me.txtPassExp.Focus()
                Exit Function
            End If
        End If

        If Me.drpWhereHear.Visibility = Windows.Visibility.Visible And Me.drpWhereHear.SelectedIndex = -1 Then
            If MsgBox("You have not provided a where hear value. Do you wish to continue?", MsgBoxStyle.YesNo, "Source") = MsgBoxResult.No Then
                Me.drpWhereHear.Focus()
                Exit Function
            End If
        End If

        Return True

    End Function

    Private Sub txtDOB_SelectedDateChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles txtDOB.SelectedDateChanged
        Me.txtDOB.Text = (New CommonFuncs).FormatDate(txtDOB.SelectedDate)
    End Sub

    Private Sub txtVisaExpiry_SelectedDateChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles txtVisaExpiry.SelectedDateChanged
        Me.txtVisaExpiry.Text = (New CommonFuncs).FormatDate(txtVisaExpiry.SelectedDate)
    End Sub

    Private Sub txtPassExp_SelectedDateChanged(ByVal sender As Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles txtPassExp.SelectedDateChanged
        Me.txtPassExp.Text = (New CommonFuncs).FormatDate(txtPassExp.SelectedDate)
    End Sub
End Class
